#ifndef _fractaltree_h_included_
#define _fractaltree_h_included_
#include <d3dx9.h>
#include <d3d9.h>
#include <string>
#include <Vector>
//#include <Math.h>
#include "Game.h"
#include "Model.h"
#include "ModelPrimitive.h"
#include <D3dx9math.h>
#include <ctime>    // For time()
#include <cstdlib>

using namespace std;

struct ExplosionNode{
	D3DXVECTOR3* Pos;
	float Radius;
	DWORD Color;
	bool Expanding;
	float mPower;
	bool Spawned;
	bool Fini;
	float Delay;
	float SmokeDiv;
};

//This class is responsible for maintaining the state
//of a model
class FractalTree
{
	protected:
	string* mName;
	float mDecayRate;
	float mExpandRate;
	float mPower;
	float mSpawnScale;
	bool ini;
	D3DXVECTOR3* mPos;
	Model* mModel;
	bool mDone;
	float mDelay;
	int mMaxDepth;

	vector<ExplosionNode*> * mNodes;
	vector<ExplosionNode*> * mTemp;
	
	public:
		FractalTree();
		void Update(float pElapsed);
		void Draw(LPDIRECT3DDEVICE9 d3ddev);
		void Reset();
		D3DXVECTOR3* CalcNewNode(D3DXVECTOR3* pos, float power);

		string* GetName(){return mName;}
		void SetName(string* pName){mName = pName;}
	float GetDecayRate(){return mDecayRate;}
	void SetDecayRate(float pDecayRate){mDecayRate = pDecayRate;}
	float GetPower(){return mPower;}
	void SetPower(float pPower){mPower = pPower;}
	float GetSpawnScale(){return mSpawnScale;}
	void SetSpawnScale(float pScale){mSpawnScale = pScale;}
	D3DXVECTOR3* GetPos(){return mPos;}
	void SetPos(D3DXVECTOR3* pPos){mPos = pPos;}
	void SetModel(Model* pModel){mModel = pModel;}
	float Random(){
	/*	int rand = ::rand()% 100 /10.0f;
		for(int a =0; a <rand; a++){
			::rand();
		}*/
		return ((::rand()% 100)/100.0f);
	}

	bool GetDone(){return mDone;}
};
#endif
